/**
 * Created by Administrator on 2017/2/9.
 * 
 */
 //var urls="http://192.168.1.107:8080/GSTX/";
 var urls="";
  $(function (){
      //数据库加载商品分类
        $.post(urls+"superMarketAction/getGoodsType",
                function(data){//data 为list
                     //循环list 取其属性值
	                $.each(data,function(n,GoodsType) {
	                $("#classifyId").append("<option value="+GoodsType.id+">"+GoodsType.goodsName+"</option>");  
	                })
                }
        ); 
    }) 
   
     //1级分类选择
       function change1(typeID,select2){
          $.post(urls+"superMarketAction/getGoodsType2",
                {
                  typeID:typeID
                },
                function(data){//data 为list
                $(select2).empty();
                var ids=0;
                     //循环list 取其属性值
	                $.each(data,function(n,GoodsType) {
	                   if(n==0){
	                     ids=GoodsType.id;
	                   }
	                $(select2).append("<option name='goodsType' value="+GoodsType.id+">"+GoodsType.goodsName+"</option>"); 
	                })
                });   
       }
  
  function prePage() { //上一页
		var page = parseInt($("#pageNum").html());
		if (page > 1) {
			page--;
			$("#pageNum").html(page)
			selectinfo();
		}
	}
	function nextPage() { //下一页
		var page = $("#pageNum").html();
		if (parseInt(page) < parseInt($("#totalpage").html())) {
			page++;
			$("#pageNum").html(page)
			selectinfo();
		}
	}
	function searchPage() { //跳到某一页
		var page = parseInt($("#searchInput").val());
		var tatalpage = parseInt($("#totalpage").html());
		if (page > tatalpage) {
			page = tatalpage;
			$("#pageNum").html(page)
			$("#searchInput").val(page);
			selectinfo();
		} else {
			if (page <= tatalpage) {
				if (page > 1) {
					$("#pageNum").html(page)
					selectinfo();
				} else {
					page = 1;
					$("#pageNum").html(page)
					selectinfo();
				}
			}
		}
	}

